<?php
	include '../ini.php';
	include '../includes/function.php';
	include '../libraries/xl_san_pham.php';
	include '../libraries/xl_loai_san_pham.php';
	$dt_xl_san_pham=new xl_san_pham;
	$dt_xl_loai_san_pham=new xl_loai_san_pham;
	if(empty($_GET['id']))
	{
		$_SESSION['msg']='Lỗi! Dữ liệu không hợp lệ, vui lòng kiểm tra lại';
		$_SESSION['type_msg']='error';
		header('Location: '.$_SERVER['HTTP_REFERER']);
		exit;
	}
	$ma=$_GET['id'];
	$san_pham=$dt_xl_san_pham->xem($ma);
	if($san_pham==NULL)
	{
		$_SESSION['msg']='Lỗi! Mã không hợp lệ, vui lòng kiểm tra lại';
		$_SESSION['type_msg']='error';
		header('Location: ..'.$_SERVER['HTTP_REFERER']);
		exit;
	}
	//$dt_xl_loai_san_pham->xem($san_pham['ma']);
	$dt_xl_san_pham->cap_nhat_lan_xem($ma);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
<?php include '../widgets/head.php'?>
</head>
<body>
<div id="art-page-background-glare">
  <div id="art-page-background-glare-image">
    <div id="art-main">
      <div class="art-sheet">
        <div class="art-sheet-tl"></div>
        <div class="art-sheet-tr"></div>
        <div class="art-sheet-bl"></div>
        <div class="art-sheet-br"></div>
        <div class="art-sheet-tc"></div>
        <div class="art-sheet-bc"></div>
        <div class="art-sheet-cl"></div>
        <div class="art-sheet-cr"></div>
        <div class="art-sheet-cc"></div>
        <div class="art-sheet-body">
          <?php include '../widgets/header.php'?>
          <?php include '../widgets/nav.php'?>
          <div class="art-content-layout">
            <div class="art-content-layout-row">
              <div class="art-layout-cell art-sidebar1">
                <?php sidebar('left');?>
                <div class="cleared"></div>
              </div>
              <div class="art-layout-cell art-content">
                <div class="art-post">
                  <div class="art-post-tl"></div>
                  <div class="art-post-tr"></div>
                  <div class="art-post-bl"></div>
                  <div class="art-post-br"></div>
                  <div class="art-post-tc"></div>
                  <div class="art-post-bc"></div>
                  <div class="art-post-cl"></div>
                  <div class="art-post-cr"></div>
                  <div class="art-post-cc"></div>
                  <div class="art-post-body">
                    <div class="art-post-inner art-article">
                    <?php thong_bao();?>
                      <h2 class="art-postheader">Chi tiết sản phẩm</h2>
                      <div class="line"> </div>
                      <div class="art-postcontent">
                      <form method="post" action="../gio-hang/them.html">
                          	<input type="hidden" name="ma" value="<?php echo $san_pham['ma']?>"/>
                        <table border="1" class="ct_sp">
                          <tr>
                            <td colspan="2" class="ten_ct"><p><?php echo $san_pham['ten'];?></p></td>
                          </tr>
                          <tr>
                            <td class="hinh_ct"><img src="../upload/products/<?php echo $san_pham['hinh'];?>" /></td>
                            <td><p>Giá bán: <?php echo $san_pham['don_gia'];?> VNĐ</p>
                              <p>Tác giả: <?php echo $san_pham['tac_gia'];?></p>
                              <p>Nhà xuất bản: <?php echo $san_pham['nha_xuat_ban'];?></p>
                              <p>Mã sản phẩm: <?php echo $san_pham['ma'];?></p>
                              <p>Tình trạng:
                                <?php if($san_pham['trang_thai']==1) echo 'còn hàng'; else echo 'hết hàng'?>
                              </p>
                              <input class="soluong" type="text" name="so_luong" value="1" />
                              <span class="art-button-wrapper"> <span class="art-button-l"> </span> <span class="art-button-r"> </span>
                            <input type="submit" name="mua_ngay" class="art-button" value="Mua ngay" />
                            </span>
                            </td>
                          </tr>
                        </table>
                        </form>
                        <a class="trove" href="../danh-sach/<?php $ma_loai=$dt_xl_loai_san_pham->xem($san_pham['ma_loai']);$ma_cha=$dt_xl_loai_san_pham->xem($ma_loai['ma_loai_cha']);echo convert_vi_to_en($ma_cha['ten']).'-'.convert_vi_to_en($ma_loai['ten']);?>-<?php echo $san_pham['ma_loai']?>.html"><< Trở về</a> </div>
                      <div class="cleared"></div>
                    </div>
                    <div class="cleared"></div>
                  </div>
                </div>
                <div class="art-post">
                  <div class="art-post-tl"></div>
                  <div class="art-post-tr"></div>
                  <div class="art-post-bl"></div>
                  <div class="art-post-br"></div>
                  <div class="art-post-tc"></div>
                  <div class="art-post-bc"></div>
                  <div class="art-post-cl"></div>
                  <div class="art-post-cr"></div>
                  <div class="art-post-cc"></div>
                  <div class="art-post-body">
                    <div class="art-post-inner art-article">
                      <h2 class="art-postheader">Sản phẩm cùng loại</h2>
                      <div class="line"> </div>
                      <div class="art-postcontent">
                        <?php
							$ds_san_pham_cung_loai=$dt_xl_san_pham->danh_sach_cung_loai($san_pham['ma_loai'],$ma);
							foreach($ds_san_pham_cung_loai as $san_pham_cung_loai)
							{
						?>
                        <form method="post" action="../gio-hang/them.html">
                          	<input type="hidden" name="ma" value="<?php echo $san_pham['ma']?>"/>
                        <div class="san_pham"> <a class="ten" href="../chi-tiet-sach/<?php echo convert_vi_to_en($san_pham_cung_loai['ten']).'-'.$san_pham_cung_loai['ma']?>.html"><?php echo cat_chuoi($san_pham_cung_loai['ten']);?><img class="hinh" src="../upload/products/<?php echo $san_pham_cung_loai['hinh'];?>" /></a> 
                          <div class="tool">
                            <div>Giá bán: <?php echo $san_pham_cung_loai['don_gia'];?> VNĐ</div>
                            <input class="soluong" value="1" name="so_luong" type="text" />
                            <span class="art-button-wrapper"> <span class="art-button-l"> </span> <span class="art-button-r"> </span>
                            <input type="submit" name="mua_ngay" class="art-button" value="Mua ngay" />
                            </span> </div>
                        </div>
                        </form>
                        <?php
							}
						?>
                      </div>
                      <div class="cleared"></div>
                    </div>
                    <div class="cleared"></div>
                  </div>
                </div>
                <div class="cleared"></div>
              </div>
              <div class="art-layout-cell art-sidebar2">
                <?php sidebar('right')?>
                <div class="cleared"></div>
              </div>
            </div>
          </div>
          <div class="cleared"></div>
          <?php include '../widgets/footer.php'?>
          <div class="cleared"></div>
        </div>
      </div>
      <div class="cleared"></div>
    </div>
  </div>
</div>
</body>
</html>
